package com.xhs.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.xhs.dto.request.CompanyParams;
import com.xhs.entity.MeBeneficiaryEntity;
import com.xhs.mapper.MeBeneficiaryMapper;
import com.xhs.message.Result;
import com.xhs.message.ReturnResult;
import com.xhs.service.MeBeneficiaryService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.xhs.entity.table.MeBeneficiaryEntityTableDef.ME_BENEFICIARY_ENTITY;

/**
 * 受益人信息表 服务层实现。
 *
 * @author xhs
 * @since 2023-07-20
 */
@Service
public class MeBeneficiaryServiceImpl extends ServiceImpl<MeBeneficiaryMapper, MeBeneficiaryEntity> implements MeBeneficiaryService {


    /**
     * 查询企业受益人信息
     *
     * @param params 查询条件
     * @return ReturnResult<Object>
     */
    @Override
    public ReturnResult<Object> getBeneficiary(CompanyParams params) {
        List<MeBeneficiaryEntity> list = queryChain().select(ME_BENEFICIARY_ENTITY.DEFAULT_COLUMNS)
                .where(ME_BENEFICIARY_ENTITY.ME_COMP_NAME.eq(params.getCompanyName()))
                .from(ME_BENEFICIARY_ENTITY)
                .list();
        return ReturnResult.build(Result.QUERY_SUCCESS).setData(list);
    }
}
